<?php
// 8/15/2009: Immanuel192 upgrade this action
if (!defined("EXPONENT")) exit("");
	$composer= null;		
	if (isset($_POST['id'])) {
		$composer = $db->selectObject('composers', 'id='.$_POST['id']);
		if ($composer != null) {
			$loc = unserialize($listing->location_data);
		} 
	} else {
		$composer->rank = $db->max('composers', 'rank', 'location_data', "location_data='".serialize($loc)."'");
		if ($composer->rank == null) {
			$composer->rank = 0;
		} else { 
			$composer->rank += 1;
		}
	}
	
	if (exponent_permissions_check("manage",$loc)) {	
		// 8/15/2009: Immanuel192 upgrade file upload to compatility with ajax file select
    $config = $db->selectObject('composersmodule_config',"location_data='".serialize($loc)."'");
		if (!$config) {
			//do nothing here yes.
      $config->image_collection=0;
      $config->composer_type=0;        
		}
    $composer = composer::update($_POST, $composer);
    // set composer_type
    $composer->composer_type = $config->composer_type;
    
		$composer->location_data = serialize($loc);
		
		if (isset($composer->id)) {
			$db->updateObject($composer,"composers");
		} else {
			$db->insertObject($composer,"composers");
		}			
		exponent_flow_redirect();
	} else {
		echo SITE_403_HTML;
	}
	

?>
